/**
 * 
 */
package com.blog.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blog.mapper.SysDeptMapper;
import com.blog.pojo.SysDept;
import com.blog.service.SysDeptService;

/**
 * @author zyj
 *
 */
@Service
public class SysDeptServiceImpl implements SysDeptService {
	
	@Autowired
	private SysDeptMapper sysDeptMapper;

	/* 
	 * 
	 */
	@Override
	public List<SysDept> findTree() {
		List<SysDept> depts = new ArrayList<SysDept>();
		List<SysDept> sysDepts = sysDeptMapper.findAll();
		for (SysDept sysDept : sysDepts) {
			if(sysDept.getParentId() == null || sysDept.getParentId() == 0) {
				depts.add(sysDept);
			}
		}
		return depts;
	}

}
